package com.ruoyi.site.mapper;

import java.util.List;
import com.ruoyi.site.domain.OrderDetails;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

/**
 * 订单详情Mapper接口
 * 
 * @author chuckeytang
 * @date 2025-08-17
 */
@Mapper
public interface OrderDetailsMapper 
{
    /**
     * 查询订单详情
     * 
     * @param orderId 订单详情主键
     * @return 订单详情
     */
    public OrderDetails selectOrderDetailsByOrderId(Long orderId);

    /**
     * 查询订单详情列表
     * 
     * @param orderDetails 订单详情
     * @return 订单详情集合
     */
    public List<OrderDetails> selectOrderDetailsList(OrderDetails orderDetails);

    /**
     * 新增订单详情
     * 
     * @param orderDetails 订单详情
     * @return 结果
     */
    public int insertOrderDetails(OrderDetails orderDetails);

    /**
     * 修改订单详情
     * 
     * @param orderDetails 订单详情
     * @return 结果
     */
    public int updateOrderDetails(OrderDetails orderDetails);

    /**
     * 删除订单详情
     * 
     * @param orderId 订单详情主键
     * @return 结果
     */
    public int deleteOrderDetailsByOrderId(Long orderId);

    /**
     * 批量删除订单详情
     * 
     * @param orderIds 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteOrderDetailsByOrderIds(Long[] orderIds);

    /**
     * 根据用户ID查询订单详情列表 (新增，供前台用户查看自己的订单)
     * * @param userId 用户ID
     * @return 订单详情集合
     */
    public List<OrderDetails> selectOrderDetailsListByUserId(Long userId);

    /**
     * 检查用户是否已购买某个 Track
     * @param userId 用户ID
     * @param trackId 音乐ID
     * @return 购买记录数量
     */
    public int countPaidPurchases(@Param("userId") Long userId, @Param("trackId") Long trackId);
}
